﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Tradex.Messaging {

    /// <summary>
    /// This is the base class for the messages passing through the Messaging framework. The "real" messages
    /// are subclasses of this message class, annotating it by additional information as needed.
    /// 
    /// Message should be immutable after sending, as the framework may distribute them to multiple recipients,
    /// not only locally but also remotely. As such, any additional field, or the items referenced in it, shoult not be
    /// changed after sending.
    /// </summary>
    [Serializable ()]
    public abstract class Message {

        /// <summary>
        /// Constructor initializing the Message.
        /// </summary>
        protected Message() {
            Id = Guid.NewGuid();
        }

        /// <summary>
        /// The unique identity of the Message.
        /// </summary>
        public Guid Id { get; internal set; }

        /// <summary>
        /// The sender of the message.
        /// </summary>
        public Address Sender { get; internal set; }

        /// <summary>
        /// The receiver of the message.
        /// </summary>
        public Address Receiver { get; set; }

        /// <summary>
        /// Flags indicating special handling of the message.
        /// </summary>
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1726:UsePreferredTerms", MessageId = "Flags")]
        public MessageFlags Flags { get; set; }

        /// <summary>
        /// The type ID of the message.
        /// </summary>
        public int MessageId { get; set; }

    }

}
